package problema053;

import java.math.BigInteger;

public class CombinatoricSelections{
	
	static BigInteger[] factoriales;
	static BigInteger cero = new BigInteger("0");
	static BigInteger millon = new BigInteger("1000000");
	
	public static void main(String[] args){
		factoriales = new BigInteger[101];
		factoriales[0] = new BigInteger("1");
		factoriales[1] = new BigInteger("1");
		BigInteger res = new BigInteger("0");
		for(int i = 2; i < factoriales.length; i++) factoriales[i] = res;
		cuantosHay();
	}
	
	public static void cuantosHay(){
		long res = 0;
		for(int n = 1; n <= 100; n++){
			for(int r = 0; r <= n; r++){
				if(combinatorio(n,r).compareTo(millon) == 1) res++;
			}
		}
		System.out.println(res);
	}
	
	public static BigInteger combinatorio(int n, int r){
		int nr = n - r;
		BigInteger res = new BigInteger("0");
		res = fact(n);
		res = res.divide(fact(r).multiply(fact(nr)));
		return res;
	}
	
	public static BigInteger fact(int n){
		if(!factoriales[n].equals(cero))return factoriales[n];
		BigInteger act = new BigInteger(Integer.toString(n));
		factoriales[n] = fact(n-1).multiply(act);
		return factoriales[n];
	}

}
